package com.wtone.platform.gat.images.gat.aspect;

import com.wtone.platform.gat.images.gat.core.Constants;
import com.wtone.platform.gat.images.gat.core.Response;
import com.wtone.platform.gat.images.gat.model.ResponseStatusListModeObject;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;

/**
 * @Author: aiLin
 * @Date: 2020/10/13 14:22
 * @desc: 全局异常处理
 */
@Slf4j
@ControllerAdvice
public class ControllerHandler {

    /**
     * 处理全部异常
     */
    @ExceptionHandler
    @ResponseBody
    @ResponseStatus(HttpStatus.OK)
    public ResponseStatusListModeObject handleException(Exception ex) {
        log.error(ex.toString());
        return Response.error("-1","", Constants.OTHERERROR,ex.toString());
    }
}
